#ifndef VSANIMSEQUENCEFUNC_H
#define VSANIMSEQUENCEFUNC_H
#include "VSAnimFunction.h"
namespace VSEngine2
{
	class VSStream;
	class VSGRAPHIC_API VSAnimSequenceFunc : public VSAnimFunction
	{
		//RTTI
		DECLARE_RTTI;
		//PRIORITY
		
	public:
		virtual ~VSAnimSequenceFunc();
		virtual bool UpdateEx(double dAppTime);
		friend class VSSkelectonMeshNode;
		VSAnimSequenceFunc(const VSUsedName & ShowName,VSAnimTree * pAnimTree);
		
		void SetAnim(const VSUsedName& AnimName);
		
		inline const VSAnim * GetAnim()const
		{
			return m_pAnim;
		}
		virtual bool PostLoad( void * pDate = NULL);
	protected:
		VSAnimSequenceFunc();
	protected:
		VSAnimPtr m_pAnim;
		VSArray<unsigned int> m_UsedBoneIndexInAnim;
		VSUsedName m_AnimName;
		struct LAST_KEY_TYPE 
		{
		public:
			LAST_KEY_TYPE()
			{
				uiLKTranslation = 0;
				uiLKScale = 0;
				uiLKRotator = 0;
			}
			~LAST_KEY_TYPE()
			{

			}
			unsigned int uiLKTranslation;
			unsigned int uiLKScale;
			unsigned int uiLKRotator;
		};
		VSArray<LAST_KEY_TYPE> m_LastKey;

		// used only in SkelectonMeshNode
		void UpDateBone();
		VSAnimSequenceFunc(VSSkelectonMeshNode * pSkelectonMeshNode);
		/* for Anim
				for UsedBoneIndexInAnim Bone */

	public:
		static bool RegisterMainFactory();
		virtual unsigned int DiskUse()const;

		virtual bool Save(VSStream & rStream,unsigned int &iSaveUse)const;
		virtual bool Load(VSStream & rStream,unsigned int &iSaveUse);
		virtual bool Link(VSStream & rStream);

		virtual bool Register(VSStream & rStream)const;
	private:
		static bool InitialClassFactory();	
		static VSObject * FactoryFunc();
		static bool ms_bRegisterMainFactory;
	public:
		virtual bool Clone(const VSObject *pObject,unsigned int uiType);

	};
	typedef VSPointer<VSAnimSequenceFunc> VSAnimSequenceFuncPtr;
}
#endif